package com.fr.report.web.ui;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public class ListEditor extends ComboBox
{
  public static final String AFTERINIT = "afterinit";
  public static final String XML_TAG = "List";
  private boolean needHead;

  public String getXType()
  {
    return "list";
  }

  public boolean isEditor()
  {
    return false;
  }

  public boolean isNeedHead()
  {
    return this.needHead;
  }

  public void setNeedHead(boolean paramBoolean)
  {
    this.needHead = paramBoolean;
  }

  public String[] supportedEvents()
  {
    return new String[] { "click", "afterinit" };
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (this.needHead)
      localJSONObject.put("needHead", this.needHead);
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("List"))
        this.needHead = true;
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.needHead)
      paramXMLPrintWriter.startTAG("List").attr("needHead", this.needHead).end();
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof ListEditor) && (super.equals(paramObject)) && (((ListEditor)paramObject).needHead == this.needHead));
  }
}